<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>删除变电站</title>
<link href="/css/allstyle.css" rel="stylesheet" type="text/css" />
<style type="text/css">
li {
	padding: 0px;
	margin: 0px;
	font-size: 14px;
	float: left;
	width: 300px;
}
.btnStyle {
	height: 25px;
	width: 150px;
	float: right;
	clear: both;
}
</style>
</head>

<body>
<div id="header"><?php include("../../job/common/header.php") ?></div>
<div id="wrap">
  <?php 
  	require("../../job/common/pdata_mysql.php");
  	if(isset($_GET['delete']) && $_GET['delete']=="on" && isset($_GET['stid']))
		{
			$sql = "DELETE FROM stations WHERE StID = ".$_GET['stid'];
			$conn = mysql_pconnect($hostname_pdata,$username_pdata,$password_pdata);
			mysql_select_db("pdata");
			if($rs = mysql_query($sql,$conn) or die(mysql_error()))
				{ echo "DELETE succeed!"; }
			else
				{ echo "DELETE failed!"; }

			mysql_close($conn);
		}
	?>
	<form method="get">
		<input name='delete' type="radio"  id='delete' />
		<input type='submit' value='删除' />
	<?php
	
	if(isset($_GET['stid']) && !isset($_GET['delete']))
	{	
	$conn = mysql_pconnect($hostname_pdata,$username_pdata,$password_pdata);
	mysql_select_db("information_schema");
	$sql = "SELECT count(*) FROM COLUMNS WHERE table_schema = 'pdata' and table_name='stations'";
	$rs = mysql_query($sql,$conn) or die(mysql_error());
	$row = mysql_fetch_array($rs);
	$maxi = $row[0];
	//echo $maxi;

	$sql = "SELECT * FROM stations WHERE StID = ".$_GET['stid'];
	mysql_select_db("pdata");
	$rs = mysql_query($sql,$conn) or die(mysql_error());
	$row = mysql_fetch_array($rs);

	echo "<ul>";
	for($i=0;$i<$maxi;$i++)
	{
		$proper = mysql_fetch_field($rs,$i);
		echo "<li>".$proper->name." : ".$row[$i]."</li>";
	}
	echo "</ul>";
	
	echo "<input type='hidden' name='stid' value='".$row[0]."'  />";
	mysql_close($conn);
	}?>
	</form>


</div>
<div id="footer"><?php include("../../job/common/footer.php") ?></div>
</body>
</html>